import React,{Component} from 'react'
import PropTypes from 'prop-types'
import Item from '../Item/Item'
import './List.css'

export default class List extends Component{

  //对接收的props进行：类型、必要性限制
  static propTypes = {
    todos:PropTypes.array.isRequired,
    changeCheck:PropTypes.func.isRequired,
    deleteTodo:PropTypes.func.isRequired
  }

  render(){
    const {todos,changeCheck,deleteTodo} = this.props
    return(
      <ul className="todo-main">
        {
          todos.map( todo =>{
            return <Item deleteTodo={deleteTodo} changeCheck={changeCheck} key={todo.id} {...todo}/>
          })
        }
      </ul>
    )
  }
}